Back to CGI Object
Up to Table of Contents
Ahead to Combo Box Object

Check Box Object

A Check Box lets the user click to select or deselect an option. Check Boxes work independently of each other. For example, if you present users with three check boxes, they can switch any number of them On or Off. Use the Check Box button to draw a Check Box object. The button appears as follows:

Check Box Object Appearance

The following figure shows an example of how a Check Box might appear within Jamba.

Note that by default, a Check Box is not checked. If you want the object to be checked by default, set its Checked property to True. Use the Label property to control the text that appears in the object and use the Font property to control the character font and size. Use the TextColor property to control the color of the characters. The BackgroundColor property sets the color for the face of the object.

Capturing the User's Input

You have the ability to pre-set a Check Box so that it is On or Off by setting its Checked property to True or False, respectively. Similarly, when a user clicks on a Check Box at runtime, its Checked property is set to True or False, when the object is checked or unchecked. In effect, the application uses the Checked property to "capture" the user's input. Your application can use this information to set another property or method at runtime.

If you want to manipulate the captured value, you refer to it using the Object.Property syntax. For example, if you want to manipulate the value currently stored in the Checked property of CheckBox1, you would specify the value CheckBox1.Checked.

Acting on the User's Input

There are two ways to use the True or False value captured in the Checked property. First, the application can use the value to set another property that uses a True or False value. For example, if the application contains CheckBox1 and Graphic1, you can set Graphic1's Visible property using CheckBox1.Checked. Second, you can send the value in CheckBox1.Checked to a CGI program for evaluation. In turn, the CGI program can return information that sets other properties and/or methods in the application.

The following subsections describe how to use the Check Box object with and without using CGI programming.

Check Boxes without CGI

This section describes how to use a Check Box without enhancing its functionality via CGI programming. As mentioned previously, you have the ability to pre-set a Check Box so that it is On or Off by setting its Checked property to True or False, respectively. Similarly, when a user clicks on a Check Box at runtime, its Checked property is set to True or False, when the object is checked or unchecked.

In effect, the application uses the Checked property to "capture" the user's input. Your application can use this information to set another property that uses the values True or False. As an example, consider a Check Box labeled "Show Pictures." You can set up your application so that the user can turn on the Check Box to view a graphic. You would set up the CheckBox1's To Do List so that when a user clicks on the Check Box, the Graphic1 object's Visible property is set to CheckBox1.Checked. Remember, CheckBox1.Checked is equal to True or False depending on whether the Check Box is On or Off. If Checked = True, Graphic1's Visible property is set to True. Otherwise, if Checked=False, Graphic1's Visible property is set to False.

For step-by-step instructions on how to create this application see the section entitled "Lesson: Check Boxes."

Check Boxes with CGI

By using a CGI object to call a CGI program, you can greatly enhance the power of Check Boxes in your applications. When a user clicks on a Check Box, you can send the Checked property (equal to True or False) out to a CGI program. The CGI program can evaluate the information and return information that sets a property or method of an object.

For example, you can use CheckBox1 labeled "Play audio" to play an Audio object called Audio1. The application would include CheckBox1, CGI1 and Audio1. The following paragraphs describe how the various objects are set up.

Audio1 - The Filename property would be set to the audio file you want to play if the user turns on the Check Box.

CheckBox1 -The To Do List would contain an item that runs the CGI object when the user clicks.

CGI1 - The ParameterList property would be set to send CheckBox1.Checked (which equals True or False depending on the state of the Check Box). The Response property would be set to True so that the CGI object expects return information. The CGI program is coded to determine whether it receives True or False. If it receives True, it returns the value Audio1.Play() which tells the Audio1 object to play the file specified for its Filename property. Otherwise, if the program receives False, it returns the value Audio1.Stop() which stops the audio from playing.

For more information, see the section entitled "CGI object."

Lesson: Check Boxes

In this lesson you set up a Check Box labeled "Show Picture" so that when the object is checked, a Graphic object becomes visible.

Note: A completed version of this applet, called lesn_9, is found in the \Jamba\lessons directory.

First set up the Graphic object. You'll set its Filename property, but initially the object will not be visible (because the "Show Picture" Check Box will be unchecked).

Use the Filename property to set the name of the graphic to display.

Next you'll set up CheckBox1.

The Checked property is set to False which is appropriate for now.

Now you'll set up CheckBox1's To Do List so that it shows the Graphic when the user clicks.

The default event is Click. Because you want the To Do List action to occur when the user clicks, you'll leave the default as is.

When you set the What To Do field to Visible, the Value field automatically displays True and False radio buttons. Because you need to type a value instead of choosing from these two options, you circumvent the default radio button options.

A typing cursor appears in the Value field, allowing you to replace the True value.

Remember, CheckBox1.Checked is equal to either True or False, depending on whether the Check Box is On or Off.